package Entities;

import Visitor.IVisitor;
import java.util.ArrayList;

public class Phase implements Drawable {

    private ArrayList<Drawable> drawableList;
    private int id;
    private int worldId;
    private String image;

    public Phase() {
        drawableList = new ArrayList<>();
        image = "";
    }

    @Override
    public Drawable accept(IVisitor visitor) {
        Drawable aux = null;
        synchronized (drawableList) {
            for (Drawable d : drawableList) {
                aux = d.accept(visitor);
                if (aux != null) {
                    return aux;
                }
            }
        }
        return null;
    }

    @Override
    public void addChild(Drawable drawable) {
        synchronized (drawableList) {
            drawableList.add(drawable);
        }
    }

    @Override
    public void remove(Drawable drawable) {
        synchronized (drawableList) {
            drawableList.remove(drawable);
        }
    }

    @Override
    public Drawable getChild(int pos) {
        synchronized (drawableList) {
            return drawableList.get(pos);
        }
    }

    @Override
    public int getNumElems() {
        return drawableList.size();
    }

    @Override
    public int getId() {
        return id;
    }

    @Override
    public void setId(int id) {
        this.id = id;
    }

    public int getWorldId() {
        return worldId;
    }

    public void setWorldId(int worldId) {
        this.worldId = worldId;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    @Override
    public double getX() {
        return 0;
    }

    @Override
    public double getY() {
        return 0;
    }
    
}
